import { BasicColumn, FormSchema } from '/@/components/Table';

const statusOptions = [
  { label: '待处理', value: 1 },
  { label: '已指派', value: 2 },
  { label: '已处理', value: 3 },
  { label: '已通过', value: 4 },
  { label: '已撤销', value: 5 },
];
const orderTypeOptions = [
  { label: '区域故障', value: 1 },
  { label: '设备故障', value: 2 },
];
export const columns: BasicColumn[] = [
  {
    title: '故障现象描述',
    dataIndex: 'faultDesc',
  },
  {
    title: '故障地点描述',
    dataIndex: 'locationDesc',
  },
  {
    title: '处理过程照片',
    dataIndex: 'processPhotos',
  },
  {
    title: '工单类型',
    dataIndex: 'orderType',
    customRender({ text }) {
      const find = orderTypeOptions.find((opt) => opt.value === text);
      return find?.label || '未定义';
    },
  },
  {
    title: '状态',
    dataIndex: 'status',
    customRender({ text }) {
      const find = statusOptions.find((opt) => opt.value === text);
      return find?.label || '未知';
    },
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    label: '故障现象描述',
    field: 'faultDesc',
    component: 'JInput',
  },
  {
    label: '工单类型',
    field: 'orderType',
    component: 'Select',
    componentProps: {
      options: orderTypeOptions,
    },
  },
  {
    label: '状态',
    field: 'status',
    component: 'Select',
    componentProps: {
      options: statusOptions,
    },
  },
];

export const formSchema: FormSchema[] = [
  { label: '', field: 'id', component: 'Input', show: false },
  {
    label: '故障现象描述',
    field: 'faultDesc',
    component: 'Input',
    required: true,
  },
  {
    label: '故障地点描述',
    field: 'locationDesc',
    component: 'Input',
  },
  {
    label: '处理过程照片',
    field: 'processPhotos',
    component: 'Input',
  },
  {
    label: '工单类型',
    field: 'orderType',
    component: 'Select',
    defaultValue: 1,
    componentProps: {
      options: orderTypeOptions,
    },
    required: true,
  },
  {
    label: '设备状态',
    field: 'status',
    component: 'Select',
    defaultValue: 1,
    componentProps: {
      options: statusOptions,
    },
    required: true,
  },
  {
    label: '*************指派人',
    field: 'assignerId',
    component: 'Input',
    required: false,
  },
  {
    field: 'assigneTime',
    label: '指派时间',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
    colProps: { span: 15 },
  },
  {
    label: '**************处理人',
    field: 'assigneeId',
    component: 'Input',
    required: false,
  },
  {
    field: 'completeTime',
    label: '处理完成时间',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
    colProps: { span: 15 },
  },
  {
    label: '处理结果反馈',
    field: 'processFeedback',
    component: 'Input',
    required: false,
  },
  {
    label: '联系人姓名',
    field: 'contactName',
    component: 'Input',
    required: false,
  },
  {
    label: '联系电话',
    field: 'contactPhone',
    component: 'Input',
    required: false,
  },
  {
    label: '备注',
    field: 'remark',
    component: 'Input',
    required: false,
  },
];
